home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Christina Milan AM to PM
/
Christina Milan - AM to PM.iso
/
christin.dir
/
00020_Script_Sway
< prev
next >
Wrap
Text File
|
2001-08-09
|
5KB
|
194 lines
-- DESCRIPTION --
on getBehaviorDescription me
return "¼
SWAY"&RETURN&RETURN&"¼
Rotates a sprite first one way then the other by a given angle per frame."&¼
RETURN&RETURN&"¼
PERMITTED MEMBER TYPES:"&RETURN&PermittedMemberTypes (me)&RETURN&RETURN&"¼
* Number of degrees to rotate in each frame"&RETURN&"¼
* Number of frames to move in each direction"&RETURN&"¼
* Initial rotation angle"&RETURN&"¼
* Start off clockwise | anticlockwise"
end getBehaviorDescription
on getBehaviorTooltip me
return "¼
Use with Bitmap, Flash, Text"&RETURN&"¼
and Vector Shape members."&RETURN&RETURN&"¼
Rotates a sprite first one"&RETURN&"¼
way then the other by a given"&RETURN&"¼
angle/frame"
end getBehaviorTooltip
-- NOTES FOR DEVELOPERS --
-- The main handler is Turn me, activated on each prepareFrame. This
-- simply decrements the myCounter property, and turns the sprite a fixed
-- angle either clockwise or anticlockwise, according to the current value
-- of the myClockwise property. When myCounter reaches zero, myClockwise
-- is set to the complementary boolean value, and myCounter is reset to
-- myFrameCount.
-- HISTORY --
-- 14 September 1998: written for the D7 Behaviors Palette by James Newton
-- 23 November 1998: descriptions revised, getPDL simplified
-- PROPERTIES --
property mySprite
-- author-defined parameters
property myAnglePerFrame
property myFrameCount
-- internal properties
property myCounter
property myClockwise
-- EVENT HANDLERS --
on beginSprite me
Initialize me
end beginSprite
on prepareFrame me
if not myCounter then ChangeDirection me
Turn me
end prepareFrame
-- CUSTOM HANDLERS --
on Initialize me -- sent by beginSprite
mySprite = sprite(me.spriteNum)
-- Error checking
memberType = mySprite.member.type
if not PermittedMemberTypes(me).getPos(memberType) then
ErrorAlert (me, #invalidMemberType, memberType)
end if
-- End of error checking
myCounter = myFrameCount
end Initialize
on Turn me -- sent by prepareFrame
myCounter = myCounter - 1
if myClockWise then
newAngle = mySprite.rotation + myAnglePerFrame
else
newAngle = mySprite.rotation - myAnglePerFrame
end if
mySprite.rotation = newAngle
end Turn
on ChangeDirection me
myClockWise = not myClockWise
myCounter = myFrameCount
end ChangeDirection
-- ERROR CHECKING --
on ErrorAlert me, theError, data
-- sent by getPropertyDescriptionList, Initialize
case theError of
#getPDLError:
alert "¼
Error: This behavior works only with the following members types: "&¼
permittedMemberTypes(me)&RETURN&RETURN&"¼
Hit OK and then delete this behavior from the sprite."&RETURN&"¼
For more information on deleting Behaviors, see the Help system."
if the optionDown then
return ¼
[ ¼
#getPDLError: ¼
[ ¼
#comment: "ERROR: Wrong member type. Click 'Cancel'.", ¼
#format: #string, ¼
#range: [""], ¼
#default: "" ¼
] ¼
]
end if
otherwise
-- Determine the behavior's name
behaviorName = string (me)
delete word 1 of behaviorName
delete the last word of behaviorName
delete the last word of behaviorName
case theError of
#invalidMemberType:
alert "¼
BEHAVIOR ERROR: Frame "&the frame&", Sprite "&me.spriteNum&RETURN&RETURN&"¼
Behavior "&behaviorName&" only functions with the following member types:"&¼
RETURN&permittedMemberTypes()&RETURN&RETURN&¼
"Current type = #"&data
halt
end case
end case
end ErrorAlert
-- AUTHOR-DEFINED PARAMETERS --
on getPropertyDescriptionList me
if not the currentSpriteNum then exit
-- Error check: does current sprite contain appropriate member type?
theMember = sprite(the currentSpriteNum).member
memberType = theMember.type
permittedTypes = PermittedMemberTypes(me)
if not permittedTypes.getPos(memberType) then
return errorAlert (me, #getPDLError, permittedTypes)
end if
return ¼
[ ¼
#myAnglePerFrame: ¼
[ ¼
#comment: "Angle to rotate in each frame:", ¼
#format: #float, ¼
#range: [#min: 0, #max: 180], ¼
#default: 10 ¼
], ¼
#myFrameCount: ¼
[ ¼
#comment: "Number of frames to move in each direction:", ¼
#format: #integer, ¼
#default: 10 ¼
] ¼
]
end getPropertyDescriptionList
on PermittedMemberTypes me
-- sent by:
-- getBehaviorDescription
-- getPropertyDescriptionList
-- Initialize
-- ErrorAlert
return [#bitmap, #flash, #text, #vectorShape]
end PermittedMemberTypes